package com.zigong.app.utils;

import android.text.TextUtils;

/**
 * Created by yuxipan on 2018-04-02.
 */

public class TimeUtils {

    public static String formatTimeToHM(String timeStr) {
        if (TextUtils.isEmpty(timeStr)) {
            return "";
        }
        String formatTime = "";
        String[] timesplit = timeStr.split(":");
        if (timesplit.length > 2) {
            String hourStr = timesplit[0];
            String minStr = timesplit[1];
            String secStr = timesplit[2];
            int minInt = 0;
            int secInt = 0;
            int hourInt = Integer.parseInt(hourStr);
            if (hourInt != 0) {
                minInt = hourInt * 60;
            }
            int minIntTemp = Integer.parseInt(minStr);
            minInt += minIntTemp;
            if (!TextUtils.isEmpty(secStr)) {
                secInt = (int) Float.parseFloat(secStr);
            } else {
                secInt = 0;
            }
            if (minInt == 0) {
                formatTime += "00'";
            } else {
                formatTime += String.valueOf(minInt) + "'";
            }
            if (secInt == 0) {
                formatTime += "00\"";
            } else {
                formatTime += String.valueOf(secInt)+"\"";
            }
        }
        return formatTime;
    }


}
